/*
 * @Author: c
 * @Date: 2024-01-08 22:13:45
 * @LastEditTime: 2024-03-09 23:58:26
 * @LastEditors: c
 * @Description: 
 * @FilePath: \music-web-backend\src\core\music\banner\banner.controller.ts
 * https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { Body, Controller, Delete, Get, Param, ParseIntPipe, Post, Put, Query, Req } from '@nestjs/common';
import { BannerService } from './banner.service';
import { BannerForm } from './dto/create-banner.dto';
import { BannerPageQuery } from './dto/search-banner.dto';

/**
 * 首页轮播图
 */
@Controller('banner')
export class BannerController {
  constructor(private readonly bannerService: BannerService) { }

  /**
   * 轮播图-创建单条数据
   * @param BannerForm 
   * @returns 
   */
  @Post()
  create(@Body() BannerForm: BannerForm) {
    return this.bannerService.create(BannerForm);
  }

  /**
    * 轮播图-分页查询
    * @param pageDto 
    * @returns 
    */
  @Get("page")
  getPage(@Req() req, @Query() pageDto: BannerPageQuery) {
    return this.bannerService.page(req.user, pageDto);
  }

  /**
   * 轮播图-获取单条数据
   * @param req 
   * @param id 
   * @returns 
   */
  @Get(':id/form')
  findOne(@Req() req, @Param('id', ParseIntPipe) id: number) {
    return this.bannerService.findOne(req.user, id);
  }

  @Put(':id')
  update(@Req() req, @Param('id', ParseIntPipe) id: number, @Body() bannerForm: BannerForm) {
    return this.bannerService.update(req.user, id, bannerForm);
  }

  @Delete(':id')
  remove(@Param('id') id: string) {
    return this.bannerService.remove(+id);
  }
}
